/**
 * 功能描述 
 */

define(function (require, exports, module) {
    var aw = require("ajaxwrapper");

    module.exports = {
    		queryChargeBackData : function(data, widget){
    			aw.ajax({
    				url: "api/signuprefund/query",
    				data: {
 					"pkServicePoint" : widget.get("subnav").getValue("servicePoint"),
 					"signUpCharge.signUpRegister.planItemGroup.pkPlanItemGroup":data.pkPlanItemGroup,
    				"fetchProperties": "pkSignUpRefund,signUpCharge.payable,refundDate,operator.pkUser,operator.name,refund,version," 
    							+ "signUpCharge.signUpRegister.pkSignUpRegister,"
    							+ "signUpCharge.signUpRegister.version,"
    							+ "signUpCharge.signUpRegister.travelContract.productRule.product.name," 
    		    				+ "signUpCharge.signUpRegister.travelContract.memberCertificates," 
    		    				+ "signUpCharge.signUpRegister.personalInfo.idNumber," 
    		    				+ "signUpCharge.signUpRegister.personalInfo.name," 
    		    				+ "signUpCharge.signUpRegister.personalInfo.sex.*,"
    		    				+ "signUpCharge.signUpRegister.personalInfo.mobilePhone"
    				},
    				dataType: "json",
    				success:function(datas){
    					var totalPay = 0;
    					if(datas){
    						for(var i=0; i< datas.length; i++){
    							if(datas[i].refund == null){
    								datas[i].refund = datas[i].signUpCharge.payable;
    								totalPay += datas[i].refund;
    							}else{
    								totalPay += datas[i].refund;
    							}
    						}
    					}
    					widget.get("form").setValue("totalAmount",totalPay.toFixed(2));
    					widget.get("editgrid").setData(datas);
    				}
    			});
    		}

    };
});
